#  路径总和
# Definition for a binary tree node.
class TreeNode:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None


class Solution:
    def pathSum(self, root: TreeNode, sum: int):
        if root is None:
            return []
        if root.left is None and root.right is None and sum == root.val:
            return [[root.val]]
        r = []
        left = self.pathSum(root.left, sum - root.val)
        for i in left:
            i.insert(0, root.val)
            r.append(i)
        right = self.pathSum(root.right, sum - root.val)
        for i in right:
            i.insert(0, root.val)
            r.append(i)
        return r


if __name__ == '__main__':
    so = Solution()
    root = TreeNode(1)
    root.left = TreeNode(0)
    root.left.right = TreeNode(-5)
    root.right = TreeNode(10)
    r = so.pathSum(root, 11)
    print(r)
